package user

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("GET")
        url("/api/users/mobilePhone") {
            queryParameters {
                parameter("mobilePhone", "12345678901")
            }
        }
    }
    response {
        status(200)
        body("""
            {
                "id":1,
                "username":"zhang",
                "password":"1234",
                "email":"1234566@qq.com",
                "mobilePhone":"12345678901",
                "createDate":123124235
            }
            """)
        bodyMatchers {
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.username', byType())
            jsonPath('$.password', byType())
            jsonPath('$.email', byRegex(email()))
            jsonPath('$.mobilePhone', byRegex(number()))
            jsonPath('$.createDate', byRegex("[\\s\\S]+"))
        }
        headers {
            header('Content-Type': 'application/json;charset=UTF-8')
        }
    }
}
